<?php
/**
 * Create by PhpStorm.
 * User: imac3
 * Date: 2021/1/25
 * Time: 4:29 下午
 */

namespace App\Models\CacheModel;

use App\Models\Api\BaseCache;
use think\Log;

/**
 * Class AppOrdersRefund
 * @package App\Models\CacheModel
 */
class AppOrdersRefund extends BaseCache
{
    protected $table = 'wechat_backup_07_18_14_43_00.app_orders_refund';
    protected $cacheModel = 'orders.refund_order';

    /**
     * 添加数据
     * @param $data
     * @return int|string
     */
    public function saveData($data)
    {
        try
        {
            $id = $this->insertGetId($data);
        }
        catch (\Exception $e)
        {
            $id = 0;
            Log::write('退款数据添加失败：' . $e->getMessage() . '文件信息【' . $e->getFile() . '：' . $e->getLine() . '】', 'error', true);
        }
        return $id;
    }

    /**
     * 批量获取数据
     * @param $ids
     * @param $type
     * @param $sortType
     * @return array|false|string|void
     */
    public function getInfoByIdsInData($ids, $type, $sortType)
    {
        try
        {
            $data = $this->where(['order_id' => ['in', $ids]])->column('uid,refund_price,order_type,trade_type,create_time', 'order_id');
        }
        catch (\Exception $e)
        {
            $data = [];
        }
        return $data;
    }
}
